package com.hsnn.medstgmini.sys.dao.impl;

import java.util.Date;
import java.util.UUID;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.hsnn.medstgmini.sys.dao.SysUserRegisterDao;
import com.hsnn.medstgmini.sys.model.AuditType;
import com.hsnn.medstgmini.sys.model.RegCompInfo;
import com.hsnn.medstgmini.sys.model.RegHospInfo;

@Repository
public class SysUserRegisterDaoImpl implements SysUserRegisterDao {

	@Resource(name = "sessionFactory")
	private SessionFactory sessionFactory;

	/**
	 * @category 保存医疗机构注册信息
	 * @date 2015年6月23日
	 * @param hospInfo
	 */
	public void saveRegHospInfo(RegHospInfo hospInfo) {
		Session session = sessionFactory.getCurrentSession();
		if (hospInfo != null) {
			hospInfo.setRegDateTime(new Date());
			hospInfo.setHospId(UUID.randomUUID().toString());
			hospInfo.setAuditStatus(AuditType.normal.getKey());
			session.save(hospInfo);
			session.flush();
		}
	}

	/**
	 * @category 保存企业注册信息
	 * @date 2015年6月23日
	 * @param compInfo
	 */
	public void saveRegCompInfo(RegCompInfo compInfo) {
		Session session = sessionFactory.getCurrentSession();
		if (compInfo != null) {
			compInfo.setRegDateTime(new Date());
			compInfo.setCompId(UUID.randomUUID().toString());
			compInfo.setAuditStatus(AuditType.normal.getKey());
			session.save(compInfo);
			session.flush();
		}
	}
}
